<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">合作方管理后台</ui:define>
    <ui:define name="content">

        <h:form>
            <p:dialog id="createModal" header="新增" position="center" widgetVar="createPrepaidModal"
                      modal="true" width="600px"
                      >
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">
                    <p:outputLabel for="username" value="用户名"/>
                    <p:inputText id="username" value="#{loanLargeAmountPartnerControlBean.$.username}" style="width:100%"/>

                    <p:outputLabel for="partnertype" value="合作方id"/>
                    <p:inputText id="partnertype" value="#{loanLargeAmountPartnerControlBean.$.partnertype}" style="width:100%"/>

                    <p:outputLabel for="partnername" value="合作方名称"/>
                    <p:inputText id="partnername" value="#{loanLargeAmountPartnerControlBean.$.partnername}" style="width:100%"/>

                    <p:outputLabel for="iscommit" value="展示提交资料数"/>
                    <p:selectOneMenu id="iscommit" value="#{loanLargeAmountPartnerControlBean.$.iscommit}">
                        <f:selectItem itemLabel="是" itemValue="是"/>
                        <f:selectItem itemLabel="否" itemValue="否"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="isapprove" value="展示提交申请数【重复】"/>
                    <p:selectOneMenu id="isapprove" value="#{loanLargeAmountPartnerControlBean.$.isapprove}">
                        <f:selectItem itemLabel="是" itemValue="是"/>
                        <f:selectItem itemLabel="否" itemValue="否"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="isdistinct" value="展示提交申请数"/>
                    <p:selectOneMenu id="isdistinct" value="#{loanLargeAmountPartnerControlBean.$.isDistinct}">
                        <f:selectItem itemLabel="是" itemValue="是"/>
                        <f:selectItem itemLabel="否" itemValue="否"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="issuccess" value="展示第二页成功申请数"/>
                    <p:selectOneMenu id="issuccess" value="#{loanLargeAmountPartnerControlBean.$.issuccess}">
                        <f:selectItem itemLabel="是" itemValue="是"/>
                        <f:selectItem itemLabel="否" itemValue="否"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="addchannelnd" value="代理渠道"/>
                    <p:selectCheckboxMenu id="addchannelnd" label="channelList" value="#{loanLargeAmountPartnerControlBean.channelList}"
                                          filter="true" filterMatchMode="startsWith"
                    >
                        <f:selectItems
                                value="#{loanLargeAmountPartnerControlBean.findAllChannelInfo()}"
                                var="channelinfo" itemValue="#{channelinfo.channel_nd}" itemLabel="#{channelinfo.channel_nd}"
                        >

                        </f:selectItems>
                    </p:selectCheckboxMenu>

                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="保存" actionListener="#{loanLargeAmountPartnerControlBean.onCreate}"
                                     process="createModal" update="@form" />
                </div>
            </p:dialog>



            <p:dialog id="editModal" header="编辑" position="center" widgetVar="editPrepaidModal"
                      modal="true" width="600px"
                      >
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">
                    <p:outputLabel for="usernameedit" value="用户名"/>
                    <p:inputText id="usernameedit" value="#{loanLargeAmountPartnerControlBean.$.username}" style="width:100%"/>

                    <p:outputLabel for="partnertypeedit" value="合作方id"/>
                    <p:inputText id="partnertypeedit" value="#{loanLargeAmountPartnerControlBean.$.partnertype}" disabled="true" style="width:100%"/>

                    <p:outputLabel for="partnernameedit" value="合作方名称"/>
                    <p:inputText id="partnernameedit" value="#{loanLargeAmountPartnerControlBean.$.partnername}" style="width:100%"/>

                    <p:outputLabel for="iscommitedit" value="展示提交资料数"/>
                    <p:selectOneMenu id="iscommitedit" value="#{loanLargeAmountPartnerControlBean.$.iscommit}">
                        <f:selectItem itemLabel="是" itemValue="是"/>
                        <f:selectItem itemLabel="否" itemValue="否"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="isapproveedit" value="展示提交申请数【重复】"/>
                    <p:selectOneMenu id="isapproveedit" value="#{loanLargeAmountPartnerControlBean.$.isapprove}">
                        <f:selectItem itemLabel="是" itemValue="是"/>
                        <f:selectItem itemLabel="否" itemValue="否"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="isdistinctedit" value="展示提交申请数"/>
                    <p:selectOneMenu id="isdistinctedit" value="#{loanLargeAmountPartnerControlBean.$.isDistinct}">
                        <f:selectItem itemLabel="是" itemValue="是"/>
                        <f:selectItem itemLabel="否" itemValue="否"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="issuccessedit" value="展示第二页成功申请数"/>
                    <p:selectOneMenu id="issuccessedit" value="#{loanLargeAmountPartnerControlBean.$.issuccess}">
                        <f:selectItem itemLabel="是" itemValue="是"/>
                        <f:selectItem itemLabel="否" itemValue="否"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="channelnd" value="代理渠道"/>
                    <p:selectCheckboxMenu id="channelnd" label="channelList" value="#{loanLargeAmountPartnerControlBean.channelList}"
                                          filter="true" filterMatchMode="startsWith"
                    >
                        <f:selectItems
                                value="#{loanLargeAmountPartnerControlBean.findAllChannelInfo()}"
                                var="channelinfo" itemValue="#{channelinfo.channel_nd}" itemLabel="#{channelinfo.channel_nd}"
                        >

                        </f:selectItems>
                    </p:selectCheckboxMenu>
                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="确认修改" actionListener="#{loanLargeAmountPartnerControlBean.onEdit}" process="editModal" update="@form"/>
                </div>
            </p:dialog>

            <p:dialog id="viewChannel" header="代理渠道" position="center" widgetVar="seechannel"
                      modal="true" width="500px"
            >
                <p:panelGrid columns="1"
                             columnClasses="ui-grid-col-12"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">
                    <p:inputTextarea rows="10" cols="50"  value="#{loanLargeAmountPartnerControlBean.channelList}" queryDelay="750" minQueryLength="4" disabled="true"/>
                </p:panelGrid>
            </p:dialog>

            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>

                        <p:columnToggler datasource="LoanWholeSaleCommentDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         rendered="#{loanLargeAmountPartnerControlBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="禁用" icon="fa fa-times"
                                         rendered="#{loanLargeAmountPartnerControlBean.isBatch()}"
                                         actionListener="#{loanLargeAmountPartnerControlBean.onBatchDisable()}"
                                         update="@form"/>
                        <p:commandButton value="启用" icon="fa fa-check"
                                         rendered="#{loanLargeAmountPartnerControlBean.isBatch()}"
                                         actionListener="#{loanLargeAmountPartnerControlBean.onBatchEnable()}"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{loanLargeAmountPartnerControlBean.isNormal()}"
                                         actionListener="#{loanLargeAmountPartnerControlBean.onReset}"
                                         process="@this" update="@form"/>
                        <p:commandButton value="新建" icon="fa fa-plus"
                                         actionListener="#{loanLargeAmountPartnerControlBean.onCreateTarget}"
                                         oncomplete="PF('createPrepaidModal').show()"
                                         process="@this" update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>

            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="ui-g-12 card">
                            <h1>查询条件</h1>
                            <div class="ui-g-1">
                                <p:outputLabel for="partnerNameInput" value="用户名"/>
                            </div>
                            <div class="ui-g-3">
                                <p:inputText id="partnerNameInput" value="#{loanLargeAmountPartnerControlBean.$.username}"/>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel value="合作方"/>
                            </div>
                            <div class="ui-g-3">
                                <p:selectOneMenu id="query_delivermethod" value="#{loanLargeAmountPartnerControlBean.$.partnertype}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems value="${loanLargeAmountPartnerControlBean.getPartnerInfo()}" var="info"
                                                   itemLabel="${info.ownername}" itemValue="${info.type}">
                                    </f:selectItems>
                                </p:selectOneMenu>
                            </div>
                        </div>
                        <div class="card">
                            <p:dataTable id="LoanWholeSaleCommentDataTable"
                                         style="width: 100%;text-align:center"
                                         var="prepaid"
                                         value="#{loanLargeAmountPartnerControlBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{loanLargeAmountPartnerControlBean.selectedRecords}"
                                         resizableColumns="true">
                                <p:column headerText="操作" style="width:70px;" rendered="#{loanLargeAmountPartnerControlBean.isNotBatch()}">
                                    <p:splitButton icon="fa fa-credit-card"
                                                   actionListener="#{loanLargeAmountPartnerControlBean.onEditTarget(prepaid)}"
                                                   oncomplete="PF('editPrepaidModal').show()"
                                                   process="@this" update="@form">
                                        <p:menuitem value="删除" icon="fa fa-times"
                                                    actionListener="#{loanLargeAmountPartnerControlBean.onDelete(prepaid.id)}"
                                                    process="@this" update="@form">
                                            <p:confirm header="信息提示" message="确定删除么？" icon="ui-icon-alert" width="10%"/>
                                        </p:menuitem>
                                        <p:menuitem value="代理渠道" icon="fa fa-arrows-alt"
                                                    oncomplete="PF('seechannel').show()"
                                                    process="@this" update="@form"/>
                                    </p:splitButton>
                                </p:column>

                                <p:column headerText="用户名">
                                    <h:outputText value="#{prepaid.username}"/>
                                </p:column>

                                <p:column headerText="合作方id" style="text-align:left;">
                                    <h:outputText value="#{prepaid.partnertype}"/>
                                </p:column>

                                <p:column headerText="合作方名称" style="text-align:right;">
                                    <h:outputText value="#{prepaid.partnername}"/>
                                </p:column>

                                <p:column headerText="展示提交资料数">
                                    <h:outputText value="#{prepaid.iscommit}"/>
                                </p:column>


                                <p:column headerText="展示提交申请数【重复】">
                                    <h:outputText value="#{prepaid.isapprove}"/>
                                </p:column>

                                <p:column headerText="展示提交申请数">
                                    <h:outputText value="#{prepaid.isDistinct}"/>
                                </p:column>

                                <p:column headerText="展示第二页成功申请数">
                                    <h:outputText value="#{prepaid.issuccess}"/>
                                </p:column>

                                <p:column headerText="来源">
                                    <h:outputText value="#{prepaid.cfrom}"/>
                                </p:column>

                                <p:column headerText="操作人">
                                    <h:outputText value="#{prepaid.updator}"/>
                                </p:column>

                                <p:column headerText="操作时间">
                                    <h:outputText value="#{prepaid.updatetime}"/>
                                </p:column>

                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
